package com.atguigu.gulimall.order.listener;

import com.atguigu.gulimall.order.service.OrderService;
import com.atguigu.gulimall.order.vo.PayAsyncVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author: xuesm
 * @date: 2025/3/11 15:26
 */
@RestController
public class OrderPayedListener {

    @Autowired
    OrderService orderService;

    @PostMapping("/payed/notify")
    public String handleAliPayed(@RequestBody PayAsyncVo payAsyncVo){
        System.out.println("支付宝通知到位...");
        payAsyncVo.setNotify_time(new Date());
        String result = orderService.handlePayResult(payAsyncVo);
        return result;
    }
}
